﻿using AppsModel.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc.Html;

namespace MVC_basic.ViewModels
{
    public class CanvasAppViewModel
    {
        [Required]
        [Display(Name = "App-Name")]
        public string name { get; set; }
        
        [Required]
        [Display(Name = "URL to a pic of your logo")]
        public string logoUrl { get; set; }
        
        [Required]
        [Display(Name = "URL to your web-application")]
        public string url { get; set; }
        
        [Range(500,1200)]
        [Display(Name = "The applications width(500-1200)")]
        public int canvasWidth { get; set; }
        
        [Range(500, 1000)]
        [Display(Name = "The applications height(500-1000)")]
        public int canvasHeight { get; set; }

        public static CanvasAppViewModel convert(CanvasApp app)
        {
            CanvasAppViewModel vm = new CanvasAppViewModel() { logoUrl = app.logoUrl, name = app.name, canvasHeight = app.canvasHeight, canvasWidth = app.canvasWidth, url = app.url };
            return vm;
        }
    }
}